home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 117 / PC Guia 117.iso / Software / Utils / Software6 / Product10 / forecastfox-0.7.1-fx+mz.xpi / install.js next >
Encoding:
Text File  |  2005-03-25  |  4.0 KB  |  92 lines

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3.  *
  4.  * The contents of this file are subject to the Mozilla Public License Version
  5.  * 1.1 (the "License"); you may not use this file except in compliance with
  6.  * the License. You may obtain a copy of the License at
  7.  * http://www.mozilla.org/MPL/
  8.  *
  9.  * Software distributed under the License is distributed on an "AS IS" basis,
  10.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11.  * for the specific language governing rights and limitations under the
  12.  * License.
  13.  *
  14.  * The Original Code is ForecastFox.
  15.  *
  16.  * The Initial Developer of the Original Code is
  17.  * Jon Stritar <jstritar@MIT.EDU>.
  18.  * Portions created by the Initial Developer are Copyright (C) 2005
  19.  * the Initial Developer. All Rights Reserved.
  20.  *
  21.  * Contributor(s):
  22.  * Jon Stritar <jstritar@MIT.EDU>
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  26.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. // package constants
  39. const DISPLAY_NAME   = "ForecastFox";
  40. const NAME           = "forecastfox";
  41. const KEY            = "/weather/" + NAME;
  42. const GUID           = "{0538E3E3-7E9B-4d49-8831-A227C80A7AD3}";
  43. const VERSION        = "0.7.1";
  44. const LOCALE_LIST    = ["en-US", "ca-AD", "el-GR", "es-ES", "fr-FR", "it-IT", "nl-NL", "pt-BR", "ru-RU", 
  45.                         "sk-SK", "sl-SI", "sv-SE", "tr-TR", "zh-CN", "zh-TW", "pl-PL", "de-DE", "cs-CZ",
  46.                         "ko-KR", "bg-BG", "da-DK"];
  47. const JAR_FILE       = NAME + ".jar";
  48. const PREFS_FILE     = "defaults/preferences/" + NAME + ".js";
  49. const AUTOREG_FILE   = "defaults/.autoreg";
  50. const XPCOM_SERVICE  = "components/nsForecastfox.js";
  51. const XPCOM_XPT      = "components/nsForecastfox.xpt";
  52. const CONTENT_FOLDER = "content/" + NAME + "/";
  53.  
  54. var err = null;
  55.  
  56. // begin the install
  57. initInstall(NAME, KEY, VERSION);
  58.   
  59. var mainDir = getFolder("Profile", "extensions/" + GUID);
  60. var chromeDir = getFolder(mainDir, "chrome");
  61.  
  62. addFile(KEY, VERSION, "chrome/"+JAR_FILE, chromeDir, null);
  63.  
  64. // Add the defaults folder
  65. var defaultDir = getFolder(mainDir, "defaults");
  66. addDirectory(KEY, VERSION, "defaults", defaultDir, null);
  67. defaultDir = getFolder(getFolder("Program", "defaults"),"pref");
  68. addFile(KEY, VERSION, PREFS_FILE, defaultDir, null);
  69.  
  70. //hack to make sure we register the component
  71. var pgmDir = getFolder("Program");
  72. addFile(KEY, VERSION, AUTOREG_FILE, pgmDir, null);
  73.  
  74. // Register the chrome URLs
  75. registerChrome(Install.CONTENT | PROFILE_CHROME, getFolder(chromeDir, JAR_FILE), "content/"+NAME+"/");
  76. registerChrome(Install.SKIN | PROFILE_CHROME, getFolder(chromeDir, JAR_FILE), "skin/classic/"+NAME+"/");
  77.  
  78. for (var x = 0; x < LOCALE_LIST.length; x++)
  79.   registerChrome(Install.LOCALE | PROFILE_CHROME, getFolder(chromeDir, JAR_FILE), "locale/"+LOCALE_LIST[x]+"/"+NAME+"/");
  80.  
  81. var compDir = getFolder("Components");
  82. addFile(KEY, VERSION, XPCOM_SERVICE, compDir, null);
  83. addFile(KEY, VERSION, XPCOM_XPT, compDir, null);
  84.  
  85. // Now install..
  86. if (getLastError() == SUCCESS) {
  87.   err = performInstall();
  88.   if ((err == SUCCESS) || (err == 999))
  89.     alert(DISPLAY_NAME + " " + VERSION + " has been installed successfully!\nPlease restart to enable the extension.");
  90. }
  91. else
  92.   cancelInstall();